from ij import IJ, WindowManager
from ij.gui import Toolbar
from time import sleep

Knight = [6,10,17,7,21,2,24,3,23,7,27,12,30,
	21,30,29,31,34,14,33,19,27,18,20,
	17,17,12,18,10,16,6,15,4,13]

def setColor(color):
	IJ.run('Colors...', 'foreground=' + color)

def path(i, j, array):
	macro = 'makePolygon('
	for k in range(0, len(array), 2):
		if k > 0:
			macro = macro + ', '
		macro = macro + str(i + array[k]) + ', ' + str(j + array[k + 1])
	macro += ');'
	IJ.runMacro(macro)
	setColor("white")
	IJ.run("Fill")

IJ.setTool(Toolbar.HAND)
imp = IJ.getImage() 
stack = imp.getImageStack()  
canvas = WindowManager.getCurrentImage().getCanvas()

while True:
	clicked = canvas.getModifiers() 
	p = canvas.getCursorLoc()
	x = int(p.x)
	y = int(p.y)
	if clicked :
		print x,' ',y 
		path(x,y,Knight)
	clicked=0
	sleep(0.1)